﻿using System.IO;
using System.Reflection;
using System.Windows.Media.Imaging;

namespace Game.Surface
{
    public static class GameImages
    {
        static BitmapImage _Arrow;
        static BitmapImage _Sword;
            
        public static BitmapImage Arrow
        {
            get
            {
                if (_Arrow != null)
                {
                    return _Arrow;
                }

                _Arrow = LoadImage("bullet_ball_glass_green.png"); ;
                return _Arrow;
            }
        }

        public static BitmapImage Sword
        {
            get
            {
                if (_Sword != null)
                {
                    return _Sword;
                }
                
                _Sword = LoadImage("button_cancel.png");;
                return _Sword;
            }
        }

        static BitmapImage LoadImage(string name)
        {
            BitmapImage image = new BitmapImage();
            string uri =
                @"Game.Surface.Resources."
                + name + "";
            Assembly a = Assembly.GetExecutingAssembly();
            Stream stream = a.GetManifestResourceStream(uri);
            
            image.BeginInit();
            image.StreamSource = stream;
            image.EndInit();

            return image;
        }
    }
}
